package com.bwie.home.backstage.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.bwie.home.backstage.entity.vo.BrokerVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bwie.home.backstage.entity.BrokerEntity;
import com.bwie.home.backstage.service.BrokerService;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.R;



/**
 * 
 *
 * @author sy
 * @email sunlightcs@gmail.com
 * @date 2021-09-28 10:26:44
 */
@RestController
@RequestMapping("backstage/broker")
public class BrokerController {
    @Autowired
    private BrokerService brokerService;

    /**
     * 展示列表
     */
    @GetMapping("/getList")
    public R getList(){
        List<BrokerVo> list = brokerService.getList();
        return R.ok().put("list",list);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = brokerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{brokerId}")
    public R info(@PathVariable("brokerId") Integer brokerId){
		BrokerEntity broker = brokerService.getById(brokerId);

        return R.ok().put("broker", broker);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody BrokerEntity broker){
		brokerService.save(broker);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody BrokerEntity broker){
		brokerService.updateById(broker);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] brokerIds){
		brokerService.removeByIds(Arrays.asList(brokerIds));

        return R.ok();
    }

}
